package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.Attendance;
import org.apache.ibatis.annotations.*;

import java.util.Date;

public interface AttendanceMapper extends BaseMapper<Attendance> {
    // 新增考勤信息
    @Insert("INSERT INTO attendance(number, id, name, departmentid, department, attendancetype, attendancetime, status) VALUES (#{number}, #{id}, #{name}, #{departmentid}, #{department}, #{attendancetype}, #{attendancetime}, #{status})")
    void insert(
            @Param("number") int number,
            @Param("id") int id,
            @Param("name") String name,
            @Param("departmentid") int departmentid,
            @Param("department") String department,
            @Param("attendancetype") String attendancetype,
            @Param("attendancetime") Date attendancetime,
            @Param("status") String status);

    // 删除考勤信息
    @Delete("DELETE FROM attendance WHERE number = #{number}")
    int deleteByNumber(int number);

    // 更新考勤信息
    @Update("UPDATE attendance SET number = #{number}, id = #{id}, name = #{name}, departmentid = #{departmentid}, department = #{department}, attendancetype = #{attendancetype}, attendancetime = #{attendancetime}, status = #{status} WHERE number = #{number}")
    int update(Attendance attendance);

    // 根据编号查询考勤信息
    @Select("SELECT number, id, name, departmentid, department, attendancetype, attendancetime, status FROM attendance WHERE number = #{number}")
    Attendance findByNumber(int number);
}